**********GLOBAL RACIST CONTAGION FOLLOWING DONALD TRUMP'S ELECTION*****************

*Supplementary Material

***Dr. Marco Giani, Assistant Professor at King's College London, Deparment of Political Economy
***Prof Pierre-Guillaume Meon, Professor at Universite Libre de Bruxelles, SBS-EM



log using supplementary

clear all
use  data.dta

set more off

*Alternative modelling
***** coasened exact matching 
ssc install cem

keep if interval==1

imb age  female domicil child minority edu hincfel uemp3m  voting , treatment (trump) //identify unbalanced covariated
cem age(15 20 24 30 34 40 44 50 54 60 64 70 74 80) domicil(#0)  country(#0), treatment (trump) //match on unbalanced covariated (according to scott-break method)
drop if cem_matched==0 //then cut un-matched
 
 
quietly: logit  race  trump age squaredage female domicil child minority edu hincfel uemp3m voting i.country [pweight=dweight], cluster(country)
margins, dydx(trump)  // 1st column
 
***** entropy balancing pooled
quietly: ebalance  trump age  female domicil child minority edu hincfel  voting uemp3m country, tar(3)
quietly: logit  race  trump age squaredage female domicil child minority edu hincfel  uemp3m voting i.country [pweight=dweight* _webal], cluster(country) 
margins, dydx(trump)  // 2nd column

***** entropy balancing per country
quietly: ebalance  trump c.age##i.country  i.female##i.country  c.domicil##i.country  i.child##i.country  i.minority##i.country  c.edu##i.country  c.hincfel##i.country i.uemp3m##i.country    i.voting##i.country  country, tar(3)
quietly: logit  race  trump age squaredage female domicil child minority edu hincfel uemp3m voting i.country [pweight=dweight* _webal], cluster(country) 
margins, dydx(trump)  // 3rd column

***** wild cluster bootstraap
ssc install clustse

*But, to use Wild wild cluster bootstraap you need an .ado called "unique", and you need to manually add it to your stata packages ( at C:\ado\plus\c)

//must create dummy variables cause wild cluster bootstraap does not allow for factor variables (i.country)


gen at=0
gen be=0
gen ch=0
gen cz=0
gen de=0
gen ee=0
gen fi=0
gen il=0
gen uk=0
gen nl=0
gen no=0
gen si=0
gen se=0

replace at=1 if country==1
replace be=1 if country==2
replace ch=1 if country==3
replace cz=1 if country==4
replace de=1 if country==5
replace ee=1 if country==6
replace fi=1 if country==7
replace il=1 if country==11
replace uk=1 if country==9
replace nl=1 if country==13
replace no=1 if country==14
replace si=1 if country==17
replace se=1 if country==18

*cgmwildboot race  trump age squaredage female domicil child minority edu hincfel  uemp3m voting at be ch cz ee de fi uk il  nl no se si [pweight= dweight], cluster(country) bootcluster(country) reps(50) seed(999)
 // 4th column

***** wild cluster bootstraap + entropy balancing per country

*cgmwildboot race  trump age squaredage female domicil child minority edu hincfel  uemp3m voting at be ch cz ee de fi uk il  nl no se si [pweight= _webal*dweight], cluster(country) bootcluster(country) reps(50) seed(999)
 // 5th column



*Entropy balanced covariates
clear all
use  data.dta

keep if  election2016==1 & interval==1
quietly:  ebalance  trump  age  female domicil  child minority edu hincfel uemp3m voting country , g(ebw) tar(3)
twoway (kdensity age if trump==1, bw(3)) (kdensity age [aweight=ebw] if trump==0, bw(3)), xtitle("age") legend(label(1 "treated") label(2 "control")) title("Age in control and treatment after entropy balancing")
twoway (kdensity edu if trump==1, bw(3)) (kdensity edu [aweight=ebw] if trump==0, bw(3)), xtitle("education") legend(label(1 "treated") label(2 "control")) title("Education in control and treatment after entropy balancing")
twoway (kdensity domicil if trump==1, bw(3)) (kdensity domicil [aweight=ebw] if trump==0, bw(3)), xtitle("domicile") legend(label(1 "treated") label(2 "control")) title("Domicile in control and treatment after entropy balancing")
twoway (kdensity hincfel if trump==1, bw(3)) (kdensity hincfel [aweight=ebw] if trump==0, bw(3)), xtitle("income") legend(label(1 "treated") label(2 "control")) title("Income in control and treatment after entropy balancing")

*Reachability 

hist attempts, fraction by(trump)

quietly:logit  race  trump age squaredage female domicil child minority edu hincfel  voting uemp3m i.country  [pweight= dweight],  cluster(country)              
quietly:margins, dydx(  trump)
est store main_regression

quietly: logit  race  trump age attempts squaredage female domicil child minority edu hincfel  voting uemp3m i.country [pweight= dweight], cluster(country)              
quietly: margins, dydx(trump)
est store controlling
 
quietly: logit  race  trump age  squaredage female domicil child minority edu hincfel  voting uemp3m i.country if attempts<3 [pweight= dweight], cluster(country)              
quietly:margins, dydx(trump)
est store without

 coefplot (main_regression) (controlling) (without), vertical keep (trump) drop(_cons) yline(0)
 
*Regional imbalance (regressions follow below)

clear all
use  data.dta

keep if election2016==1


histogram regione,  by(trump, col(1))  xtitle("Regions in Austria before (above) and after (below) the election") note("Source: ESS8")

twoway (hist regione if trump==0 & country==1, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==1, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Austria. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==2, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==2, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Belgium. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==3, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==3, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Switzerland. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==4, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==4, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Czech Republic . Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==5, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==5, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Germany. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==6, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==6, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Estonia. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==7, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==7, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Finland. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==9, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==9, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("UK. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==13, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==13, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Netherlands. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==14, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==14, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Norway. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==17, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==17, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Sweden. Sample by region Before (grey) and After (red) the election.")

twoway (hist regione if trump==0 & country==18, frac width(.25) barw(.35) bfcolor(none) blcolor(gray)) (hist regione if trump==1 & country==18, frac width(.25) barw(.35) bfcolor(none) blcolor(red)), legend(off) xtitle("Slovack Republic. Sample by region Before (grey) and After (red) the election.")

keep if interval==1

quietly: ebalance  trump age  female domicil child minority edu hincfel uemp3m voting country, tar(3)
quietly: logit  race  trump age squaredage female domicil child minority edu hincfel  voting uemp3m i.country [pweight= _webal*dweight], cluster(country)              
margins, dydx(  trump)
est store regionally_unbalanced
 
quietly: ebalance  trump age  female domicil child minority edu hincfel uemp3m voting country region, tar(3)
quietly: logit  race  trump age squaredage female domicil child minority edu hincfel  voting uemp3m i.country i.regione [pweight= _webal*dweight], cluster(country)              
margins, dydx(  trump)
est store regionally_balanced

/// shows that controlling for region-imbalance does not change the main treatment effect

 coefplot (regionally_unbalanced) (regionally_balanced), vertical keep (trump) drop(_cons) yline(0)


 *Alternative dependent variables

quietly:  ebalance  trump  age  female domicil  child minority edu hincfel uemp3m voting country if election2016==1 & interval==1 , tar(3)
quietly: logit  race  trump age squaredage female domicil child minority edu hincfel  uemp3m voting i.country [pweight= _webal*dweight] if election2016==1 & interval==1, cluster(country)              
est store a1
quietly: ologit  race2  trump age squaredage female domicil child minority edu hincfel  uemp3m voting i.country [pweight= _webal*dweight] if election2016==1 & interval==1, cluster(country)              
est store a2
quietly: ologit  race3  trump age squaredage female domicil child minority edu hincfel  uemp3m voting i.country [pweight= _webal*dweight] if election2016==1 & interval==1, cluster(country)              
est store a3


esttab a1 a2 a3 , keep(trump) se obslast collabels(, none)  star(* 0.10 ** 0.05 *** 0.01)  wrap    nonumbers cells(b(star fmt(3)) se(fmt(3) par)) compress  

 
*Missing data  

clear all
use data.dta

keep if election2016==1

gen miss=0
replace miss=1 if race==.


bysort trump: sum miss

quietly: logit  miss  trump age squaredage female domicil child minority edu hincfel  voting uemp3m i.country  [pweight= dweight],  cluster(country)              
margins, dydx(  trump)
 
 
gen miss_before=0  if miss==0 & trump==0
replace miss_before=1 if miss==1 & trump==0

gen miss_after=0 if miss==0 & trump==1
replace miss_after=1 if miss==1 & trump==1
 
 *descriptive level shows similarity in what correlated with missingness of response on "racial bias"
 
pwcorr miss_before age   female domicil child minority edu hincfel  voting uemp3m,   star(.05)
pwcorr miss_after age  female domicil child minority edu hincfel  voting uemp3m,   star(.05)

quietly: ebalance  trump age  female domicil child minority edu hincfel uemp3m voting country, tar(3)
quietly: logit  miss_before    age squaredage female domicil child minority edu hincfel  voting uemp3m i.country  [iweight= dweight*_webal]  
est store before         
quietly: logit  miss_after    age squaredage female domicil child minority edu hincfel  voting uemp3m i.country  [iweight= dweight*_webal]     
est store after

quietly:suest before after  ,   cluster(country)      

*Tests in Table "missing data" in the Appendix

test [before_miss_before]age -  [after_miss_after]age = 0
test [before_miss_before]female-  [after_miss_after]female = 0
test [before_miss_before]domicil-  [after_miss_after]domicil = 0
test [before_miss_before]child-  [after_miss_after]child = 0
test [before_miss_before]minority-  [after_miss_after]minority = 0
test [before_miss_before]edu-  [after_miss_after]edu = 0
test [before_miss_before]hincfel-  [after_miss_after]hincfel = 0
test [before_miss_before]voting-  [after_miss_after]voting = 0
test [before_miss_before]uemp3m-  [after_miss_after]uemp3m = 0
test [before_miss_before]voting-  [after_miss_after]voting = 0


*Treeatment effects with varying Time intervals 


clear all
use data.dta

keep if election2016==1


quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(13nov2016) & edate>d(4nov2016), tar(3)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(13nov2016) & edate>d(4nov2016), cluster(country) 
quietly: margins, dydx(trump) predict(outcome(1))  post
est store _5_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(18nov2016) & edate>d(30oct2016)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(18nov2016) & edate>d(30oct2016), cluster(country) 
quietly: margins, dydx(trump)  predict(outcome(1)) post
est store _10_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(23nov2016) & edate>d(25oct2016)
quietly:ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(23nov2016) & edate>d(25oct2016), cluster(country) 
quietly:margins, dydx(trump) predict(outcome(1)) post
est store _15_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(28nov2016) & edate>d(20oct2016)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(28nov2016) & edate>d(20oct2016), cluster(country)
quietly: margins, dydx(trump) predict(outcome(1)) post
est store _20_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(3dec2016) & edate>d(15oct2016)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(3dec2016) & edate>d(15oct2016), cluster(country) 
quietly: margins, dydx(trump) predict(outcome(1)) post
est store _25_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(8dec2016) & edate>d(10oct2016)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(8dec2016) & edate>d(10oct2016), cluster(country) 
quietly: margins, dydx(trump) predict(outcome(1)) post
est store _30_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(23dec2016) & edate>d(26sep2016)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(23dec2016) & edate>d(26sep2016), cluster(country) 
quietly: margins, dydx(trump) predict(outcome(1)) post
est store _45_days
quietly: ebalance  trump  age squaredage female domicil child minority edu hincfel  voting country if edate<d(7jan2017) & edate>d(11sep2016)
quietly: ologit  race  trump age squaredage female domicil child minority edu hincfel voting i.country [pweight= _webal*dweight] if edate<d(7jan2017) & edate>d(11sep2016), cluster(country) 
quietly: margins, dydx(trump) predict(outcome(1)) post
est store _60_days

coefplot (_5_days, label(one) pstyle(p3)) (_10_days, label(two)  pstyle(p4))  (_15_days, label(three)  pstyle(p5)) (_20_days, label(four)  pstyle(p6))  (_25_days, label(five)  pstyle(p7)) (_30_days, label(six)  pstyle(p8)) (_45_days, label(seven)  pstyle(p9)) (_60_days, label(eight)  pstyle(p10)) , vertical legend(off) keep(trump) xlabel("") yline(0) msymbol(S) title("Treatment effects for varying time bandwidths (5-60 days)" )

*By country

clear all
use data.dta

keep if interval==1

gen at=0
gen be=0
gen ch=0
gen cz=0
gen de=0
gen ee=0
gen fi=0
gen il=0
gen uk=0
gen nl=0
gen no=0
gen si=0
gen se=0

replace at=1 if country==1
replace be=1 if country==2
replace ch=1 if country==3
replace cz=1 if country==4
replace de=1 if country==5
replace ee=1 if country==6
replace fi=1 if country==7
replace il=1 if country==11
replace uk=1 if country==9
replace nl=1 if country==13
replace no=1 if country==14
replace si=1 if country==17
replace se=1 if country==18
 

gen interat = trump*at
gen interbe = trump*be
gen interch = trump*ch
gen intercz = trump*cz
gen interde = trump*de
gen interee = trump*ee
gen interfi = trump*fi
gen interuk = trump*uk
gen interil = trump*il
gen internl = trump*nl
gen interno = trump*no
gen interse = trump*se
gen intersi = trump*si


ebalance  trump age  female domicil child minority edu hincfel uemp3m voting country, tar(3)

quietly: reg race  trump interat age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interat)
quietly: reg race  trump interbe age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interbe)
quietly: reg race  trump interch age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interch)
quietly: reg race  trump intercz age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump intercz)
quietly: reg race  trump interde age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interde)
quietly: reg race  trump interee age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interee)
quietly: reg race  trump interfi age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interfi)
quietly: reg race  trump interuk age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interuk)
quietly: reg race  trump interil age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interil)
quietly: reg race  trump internl age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump internl)
quietly: reg race  trump interno age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interno)
quietly: reg race  trump interse age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump interse)
quietly: reg race  trump intersi age squaredage edu hincfel uemp3m female child domicil minority voting i.country [pweight= _webal*dweight], cluster(country)
margins, dydx(  trump intersi)



log close
